﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;

namespace MODASA.HojaDefinicionProducto
{
    public partial class HDPAsiento : System.Web.UI.Page
    {

        DataTable HDP;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["HDP"] == null)
            {
                Page.Response.Redirect("HDPModelos.aspx");

            }  
        }





        protected void RBLCANT1N_SelectedIndexChanged(object sender, EventArgs e)
        {
            Asiento_Cantidad(RBLCANT1N.SelectedValue,1);
        }

        protected void RBLCANT2NCB_SelectedIndexChanged(object sender, EventArgs e)
        {

            
            Asiento_Cantidad(RBLCANT2NCB.SelectedValue, 2);
            
        }

        private void Asiento_Cantidad(string dat, int niv){

            string val = dat.Substring(0, 4);
            int can = Convert.ToInt16(dat.Substring(5, 2));

            if (niv == 1)
            {
                HLASICAN1N1.ImageUrl = "../images/Buses/ImgInt/Asientos/Asientos/m_" + val + "1.jpg";
                HLASICAN1N1.NavigateUrl = "../images/Buses/ImgInt/Asientos/Asientos/" + val + "1.jpg";
                HLASICAN1N2.ImageUrl = "../images/Buses/ImgInt/Asientos/Asientos/m_" + val + "2.jpg";
                HLASICAN1N2.NavigateUrl = "../images/Buses/ImgInt/Asientos/Asientos/" + val + "2.jpg";
                HLASICAN1N3.ImageUrl = "../images/Buses/ImgInt/Asientos/Asientos/m_" + val + "3.jpg";
                HLASICAN1N3.NavigateUrl = "../images/Buses/ImgInt/Asientos/Asientos/" + val + "3.jpg";

                Añadir_Row_HDP("AsientosPrimerNivelCantidad", can.ToString());
                Añadir_Row_HDP("AsientosPrimerNivelTipo", val.ToString());
            }
            else
            {
                HLASICAN2N1.ImageUrl = "../images/Buses/ImgInt/Asientos/Asientos/m_" + val + "1.jpg";
                HLASICAN2N1.NavigateUrl = "../images/Buses/ImgInt/Asientos/Asientos/" + val + "1.jpg";
                HLASICAN2N2.ImageUrl = "../images/Buses/ImgInt/Asientos/Asientos/m_" + val + "2.jpg";
                HLASICAN2N2.NavigateUrl = "../images/Buses/ImgInt/Asientos/Asientos/" + val + "2.jpg";
                HLASICAN2N3.ImageUrl = "../images/Buses/ImgInt/Asientos/Asientos/m_" + val + "3.jpg";
                HLASICAN2N3.NavigateUrl = "../images/Buses/ImgInt/Asientos/Asientos/" + val + "3.jpg";

                Añadir_Row_HDP("AsientosSegundoNivelCantidad", can.ToString());
                Añadir_Row_HDP("AsientosSegundoNivelTipo", val.ToString());
            }      
        }

        private void Añadir_Row_HDP(string A, string B)
        {

            HDP = (DataTable)Session["HDP"];


            for (int x = 0; x < HDP.Rows.Count; x++)
            {
                string A1 = HDP.Rows[x][0].ToString();

                if (A1.ToString() == A.ToString())
                {
                    HDP.Rows.RemoveAt(x);

                }
            }

            HDP.Rows.Add(A, B);


        }

        protected void CBOTRCARAPOY1N_CheckedChanged(object sender, EventArgs e)
        {
            if (CBOTRCARAPOY1N.Checked == true)
            {
                Añadir_Row_HDP("ApoyoColumbioPrimerNivel", "SI");
            }
            else { Añadir_Row_HDP("ApoyoColumbioPrimerNivel", "NO"); }
            
        }

        protected void CBOTRCARAPOY2N_CheckedChanged(object sender, EventArgs e)
        {
            if (CBOTRCARAPOY2N.Checked == true)
            {
                Añadir_Row_HDP("ApoyoColumbioSegundoNivel", "SI");
            }
            else {
                Añadir_Row_HDP("ApoyoColumbioSegundoNivel", "NO");
            }
        }

        protected void CBOTRCARVELC1N_CheckedChanged(object sender, EventArgs e)
        {
            if (CBOTRCARVELC1N.Checked == true)
            {
                Añadir_Row_HDP("VelcroPrimerNivel", "SI");
            }
            else
            {
                Añadir_Row_HDP("VelcroPrimerNivel", "NO");
            }
        }

        protected void CBOTRCARVELC2N_CheckedChanged(object sender, EventArgs e)
        {
            if (CBOTRCARVELC2N.Checked == true)
            {
                Añadir_Row_HDP("VelcroSegundoNivel", "SI");
            }
            else
            {
                Añadir_Row_HDP("VelcroSegundoNivel", "NO");
            }
        }

        protected void RBLCOPICANT_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("CopilotoCantidad", RBLCOPICANT.Text);
        }

        protected void RBLCOPITIP_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("CopilotoTipo",RBLCOPITIP.Text);
        }

        protected void RBLCOPIFORR_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("CopilotoForrado",RBLCOPIFORR.Text);
        }

        protected void RBLPILFORR_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("PilotoForrado",RBLPILFORR.Text);
        }

        protected void RBLCANT2NSB_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void RBLFORRCAR1N_SelectedIndexChanged(object sender, EventArgs e)
        {
            HabilitarDesabilitarOpTelas(RBLFORRCAR1N.SelectedValue.ToString());
        }

        private void HabilitarDesabilitarOpTelas(string res) {
            if (res == "TELA") {

                HLFORRO1N.ImageUrl = "../images/Buses/ImgInt/Asientos/Forro/m_Tela1.png";
                HLFORRO1N.NavigateUrl = "../images/Buses/ImgInt/Asientos/Forro/Tela1.png";
                DLFORRCAR1N.Enabled = true;
                CargarForroTela(DLFORRCAR1N.Text);

            }else if (res == "CUERO") { 

                DLFORRCAR1N.Enabled = false;
                HLFORRO1N.ImageUrl = "../images/Buses/ImgInt/Asientos/Forro/m_Cuero1.png";
                HLFORRO1N.NavigateUrl = "../images/Buses/ImgInt/Asientos/Forro/Cuero1.png";
                HLFORROTELA.ImageUrl = "../images/Buses/ImgInt/Asientos/Tela/m_Cuero.png";
                HLFORROTELA.NavigateUrl = "../images/Buses/ImgInt/Asientos/Tela/Cuero.png";

            }

        }

        protected void RBLFORRCAR2N_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void DLFORRCAR1N_SelectedIndexChanged(object sender, EventArgs e)
        {
            CargarForroTela(DLFORRCAR1N.Text);
        }
        private void CargarForroTela(string res) {
            HLFORROTELA.ImageUrl = "../images/Buses/ImgInt/Asientos/Tela/m_" + res+ ".png";
            HLFORROTELA.NavigateUrl = "../images/Buses/ImgInt/Asientos/Tela/" + res + ".png";
        }

    }
}